<?php
	// Author: Andy Marti
	// Datum: 12.03.2014
	// ----------------------------------------------------
	// Beschreibung Klasse:
	//   Die Klasse enthält alle Eigenschaften und Methoden eines einzelnen Members. 
	//   Diese Klasse hat als Properties Association und CommitteeTask. 
	//   Sie wird als Property der Klasse User übergeben. 
	//   Die Klasse verwaltet den MemberState.
	// ----------------------------------------------------
	// Änderungen:
	//
	// ----------------------------------------------------
	
	require_once 'user.php';
	require_once 'association.php';
	require_once 'committee_task.php';


	/**
	 * Klasse beschreibt ein Member des Clubs. Abgeleitet von Klasse User.
	 * 
	 * @author andy
	 *
	 */
	class Member extends User {
		// Public Variables.
		public $MemberState = '';
		public $MemberStateID = -1;
		public $FamilyFlag = False;
		public $MemberID = -1;
		public $MemberFee = -1;
		// Private Variables.
		// Public Objects.
		public $Associations = NIL;
		public $CommitteeTasks = NIL;
		// Private Objects.
		//

		// ------------------------------------------------
		// Public methodes.
		/**
		 * Get the user and member data from database.
		 *
		 * @param unknown $extuserid
		 */
		public function getUserData($extuserid, $loggedinuserid) {
			// Check basic and parameter.
			If ($this->checkInitial()) {
				If (empty($extuserid)) {
					$this->Messages->throwMessage($this->Messages->NumWrongUserId, '');
				}
				// Get user from UserDB object.
				parent::getUserData($extuserid, $loggedinuserid);
				// Get member from UserDB Object.
				$this->UserDb->getMemberData($this, $this->UserID);
				// Set Association and CommitteeTask data.
				$this->Associations->getAssociationData($this->MemberID);
				$this->CommitteeTasks->getCommitteeTaskData($this->MemberID);
			}
		}

		/**
		 * Set the member data into database.
		 *
		 */
		public function setMemberData() {
			// Check basic and parameter.
			If ($this->checkInitial()) {
				// Set all member data in UserDB object.
				parent::setJobs();
				$this->UserDb->setMemberData($this);
				$this->UserDb->setAssociations($this);
				$this->UserDb->setCommitteeTasks($this);
			}
		}

		/**
		 * Set the member data into database.
		 *
		 */
		public function newMember() {
			// Check basic and parameter.
			If ($this->checkInitial()) {
				// Set all member data in UserDB object.
				parent::setJobs();
				$this->UserDb->newMemberData($this);
				$this->UserDb->setAssociations($this);
				$this->UserDb->setCommitteeTasks($this);
			}
		}
		
		/**
		 * Init the User Object.
		 *
		 */
		public function initUser() {
			// check basic.
			If ($this->checkInitial()) {
				// Set internal objects.
				parent::initUser();
				$this->Associations->Messages = $this->Messages;
				$this->Associations->UserDb = $this->UserDb;
				$this->CommitteeTasks->Messages = $this->Messages;
				$this->CommitteeTasks->UserDb = $this->UserDb;
			}
		}
		
		// ------------------------------------------------
		// Contructor, Destructor.
		/**
		 * Construtor. 
		 * 
		 */
		public function __construct(){
			// Create class objects.
			parent::__construct();
			$this->Associations = new Association();
			$this->CommitteeTasks = new CommitteeTask();
		}
		
		/**
		 * Destructor.
		 *
		 */
		public function __destruct(){
			// Destroy internal objects.
			$this->Associations = NIL;
			$this->CommitteeTasks = NIL;
		}
	}
?>